<template>
  <div>
    <el-row :gutter="15">
      <el-col :span="10">
        <el-form ref="form" :model="form" label-width="150px">
          <el-form-item label="开关">
            <el-switch
              v-model="form.iEnable"
              active-value="1"
              inactive-value="0"
            ></el-switch>
          </el-form-item>
          <el-form-item label="是否认证">
            <el-switch
              v-model="form.iAuthEnable"
              active-value="1"
              inactive-value="0"
            ></el-switch>
          </el-form-item>
          <el-form-item label="打包大小">
            <el-input
              v-model="form.iPackageSize"
              type="number"
              placeholder="请输入打包大小"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="端口">
            <el-input
              v-model="form.iPort"
              type="number"
              placeholder="请输入打包大小"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="通讯模式">
            <el-select v-model="form.sProtocol" placeholder="请选择通讯模式">
              <el-option label="广播" value="broadcast"></el-option>
              <el-option label="组播" value="multicast"></el-option>
              <el-option label="单播" value="unicast"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="多播地址">
            <el-input
              v-model="form.sMulticastAddress"
              placeholder="请输入多播地址"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="主码流多播视频端口">
            <el-input
              v-model="form.iMainMulticastVideoPort"
              type="number"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="主码流多播音频端口">
            <el-input
              v-model="form.iMainMulticastAudioPort"
              type="number"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="次码流多播视频端口">
            <el-input
              v-model="form.iSubMulticastVideoPort"
              type="number"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="次码流多播音频端口">
            <el-input
              v-model="form.iSubMulticastAudioPort"
              type="number"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <!-- <el-form-item label="Onvif密码验证">
            <el-switch v-model="form.isPWValidate"></el-switch>
          </el-form-item> -->

          <el-form-item>
            <el-button type="primary" @click="onSubmit">保存</el-button>
          </el-form-item>
        </el-form></el-col
      >
    </el-row>
  </div>
</template>

<script>
import { getRtspConfigApi, editRtspConfigApi } from "@/api/network";
export default {
  data() {
    return {
      form: {
        iEnable: "",
        iAuthEnable: "",
        iPackageSize: "",
        iPort: "",
        sProtocol: "",
        sMulticastAddress: "",
        iMainMulticastVideoPort: "",
        iMainMulticastAudioPort: "",
        iSubMulticastVideoPort: "",
        iSubMulticastAudioPort: "",
        // isPWValidate: "",
      },
    };
  },
  created() {
    this.getRtspConfig();
  },
  mounted() {},

  methods: {
    getRtspConfig() {
      getRtspConfigApi().then((res) => {
        // console.log(res);
        this.form = res[0];
      });
    },
    onSubmit() {
      // console.log("submit!");
      editRtspConfigApi(this.form).then((res) => {
        // console.log(res);
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
